package day0817;

import java.util.Arrays;

/**
 * @Author:galaxy_yan
 * @Date: 2022/8/17
 * @Time: 18:37
 * @Description
 * 作业标题(2434)
 * 两数之和
 */
public class text4 {
    public static void main(String[] args) {
        int[] arr={2,7,11,15};
        System.out.println(Arrays.toString(func(arr,9)));
    }

    private static int[] func(int[] arr, int target) {
        int[] array=new int[2];
        for (int i = 0; i < arr.length-1; i++) {
            for (int j = i+1; j < arr.length; j++) {
                if(arr[i]+arr[j]==target){
                    array[0]=i;
                    array[1]=j;
                }
            }
        }
        return array;
    }
}
